using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class EpisodeDoctorRelMap : EntityTypeConfiguration<EpisodeDoctorRel>
	{
		public EpisodeDoctorRelMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			// Table & Column Mappings
			this.ToTable("EpisodeDoctorRels");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.DoctorId).HasColumnName("DoctorId");
			this.Property(t => t.RecordTime).HasColumnName("RecordTime");
			this.Property(t => t.RecordStatus).HasColumnName("RecordStatus");
			this.Property(t => t.EpisodeId).HasColumnName("EpisodeId");

			// Relationships
			this.HasOptional(t => t.Episode)
				.WithMany(t => t.EpisodeDoctorRels)
				.HasForeignKey(d => d.EpisodeId);
				
		}
	}
}

